#ifndef __EKOS_USER_FS_H__
#define __EKOS_USER_FS_H__

typedef uint32_t faddr_t;
typedef uint32_t fid_t;

struct fs_stat_t
{
	 uint32_t type;
	 uint32_t size;
};

#define FILE_REGULAR   0
#define FILE_DIRECTORY 1

/* file system interface definition */
typedef int (*fs_driver_read_t)(void *dev, fid_t id, faddr_t start, int size, physaddr_t addr);
typedef int (*fs_driver_write_t)(void *dev, fid_t id, faddr_t start, int size, physaddr_t addr);
typedef int (*fs_driver_stat_t)(void *dev, fid_t id, struct fs_stat_t *attr);
typedef int (*fs_driver_create_t)(void *dev, fid_t *id);
typedef int (*fs_driver_remove_t)(void *dev, fid_t id);
typedef int (*fs_driver_open_t)(void *dev, fid_t id);
typedef int (*fs_driver_close_t)(void *dev, fid_t id);

struct fs_driver_t
{
	 fs_driver_read_t   read;
	 fs_driver_write_t  update;
	 fs_driver_stat_t   stat;
	 fs_driver_create_t create;
	 fs_driver_remove_t remove;
	 fs_driver_open_t   open;
	 fs_driver_close_t	close;
};

struct fs_device_t
{
	 void *data;
	 struct fs_driver_t *drv;
};

struct fs_node_t
{
	 struct fs_device_t *dev;
	 union
	 {
		  fid_t id;
		  /* For free list */
		  struct fs_node_t *free_next;
	 };
};

void fs_start(void);

#define FS_OPEN_ROOT
#define FS_MAP_PAGE

#endif
